package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.DsChargingInfo;
import com.ruoyi.system.service.IDsChargingInfoService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 计费管理Controller
 * 
 * @author ruoyi
 * @date 2024-06-05
 */
@RestController
@RequestMapping("/system/chargingInfo")
public class DsChargingInfoController extends BaseController
{
    @Autowired
    private IDsChargingInfoService dsChargingInfoService;

    /**
     * 查询计费管理列表
     */
    @PreAuthorize("@ss.hasPermi('system:chargingInfo:list')")
    @GetMapping("/list")
    public TableDataInfo list(DsChargingInfo dsChargingInfo)
    {
        startPage();
        List<DsChargingInfo> list = dsChargingInfoService.selectDsChargingInfoList(dsChargingInfo);
        return getDataTable(list);
    }

    /**
     * 导出计费管理列表
     */
    @PreAuthorize("@ss.hasPermi('system:chargingInfo:export')")
    @Log(title = "计费管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DsChargingInfo dsChargingInfo)
    {
        List<DsChargingInfo> list = dsChargingInfoService.selectDsChargingInfoList(dsChargingInfo);
        ExcelUtil<DsChargingInfo> util = new ExcelUtil<DsChargingInfo>(DsChargingInfo.class);
        util.exportExcel(response, list, "计费管理数据");
    }

    /**
     * 获取计费管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:chargingInfo:query')")
    @GetMapping(value = "/{chargingId}")
    public AjaxResult getInfo(@PathVariable("chargingId") Long chargingId)
    {
        return success(dsChargingInfoService.selectDsChargingInfoByChargingId(chargingId));
    }

    /**
     * 新增计费管理
     */
    @PreAuthorize("@ss.hasPermi('system:chargingInfo:add')")
    @Log(title = "计费管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DsChargingInfo dsChargingInfo)
    {
        return toAjax(dsChargingInfoService.insertDsChargingInfo(dsChargingInfo));
    }

    /**
     * 修改计费管理
     */
    @PreAuthorize("@ss.hasPermi('system:chargingInfo:edit')")
    @Log(title = "计费管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DsChargingInfo dsChargingInfo)
    {
        return toAjax(dsChargingInfoService.updateDsChargingInfo(dsChargingInfo));
    }

    /**
     * 删除计费管理
     */
    @PreAuthorize("@ss.hasPermi('system:chargingInfo:remove')")
    @Log(title = "计费管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{chargingIds}")
    public AjaxResult remove(@PathVariable Long[] chargingIds)
    {
        return toAjax(dsChargingInfoService.deleteDsChargingInfoByChargingIds(chargingIds));
    }
}
